package com.hy.controller;


import com.hy.ResultCodeEnum;
import com.hy.pojo.Draft;
import com.hy.service.DraftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/drafts")
public class DraftController {
    @Autowired
    private DraftService draftService;

    @PostMapping("/createDraft")
    public void createDraft(@RequestBody Draft draft) {
         draftService.createDraft(draft);
    }

    @DeleteMapping("/deleteDraft/{id}")
    public void deleteDraft(@PathVariable Long id) {
        draftService.deleteDraft(id);
    }

    @PutMapping("/updateDraft")
    public void updateDraft(@RequestBody Draft draft) {
        draftService.updateDraft(draft);
    }

    @GetMapping("/getDraftById/{id")
    public List<Draft> getDraft(@PathVariable Long id) {
        return draftService.getDraftById(id);
    }

    @GetMapping("/getDraftsByUserId/{userId}")
    public List<Draft> getUserDrafts(@PathVariable Long userId) {
        return draftService.getDraftsByUserId(userId);
    }
}
